/*
 * @Author: your name
 * @Date: 2021-11-22 17:02:26
 * @LastEditTime: 2022-10-09 20:59:48
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \JvMEs9.1\src\jv_doc\utils\system\enumsPlugin.js
 */
// 枚举转list
export function enumToList(map, labelField = "label") {
  let typeArr = [];
  for (const key in map) {
    typeArr.push({
      [labelField]: map[key].name,
      value: map[key].value,
    });
  }
  return typeArr;
}
// 枚举过滤
export function enumFilter(value = undefined, enums = {}) {
  if (!value) return "--";
  return enums?.[value]?.name ?? value;
}
// 枚举名称过滤
export function enumNameFilter(value = undefined, enums = {}) {
  let result = "";
  for (const key in enums) {
    if (enums[key].name == value) {
      result = enums[key].value;
    }
  }
  return result;
}
